/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2021-11-19 10:52:34
 * 天凉好个秋
 */

import { Context } from "koa";

/**
 * @description: 解析请求参数
 * @param {Context} ctx
 * @return {*}  返回请求参数
 */
export default (ctx: Context) => {
    let params;
    switch (ctx.method) {
        case 'GET':
            params = ctx.query
            break;
        case 'POST':
            params = ctx.request.body
            break;
        case 'PUT':
            params = ctx.request.body
            break;
        case 'DELETE':
            params = ctx.query
            break;
        default:
            params = `暂不支持${ctx.method}类型的请求`
            break;    
    }
    return params
}